//
//  GHHomeHeaderCollectionViewCell.m
//  GreenHome
//
//  Created by Mac on 2018/10/17.
//  Copyright © 2018年 stoneobs.qq.com. All rights reserved.
//

#import "BLLifeCollectionViewCell.h"

@implementation BLLifeCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self configSubView];
    }
    return self;
}
#pragma mark --subView
- (void)configSubView{
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 120)];
    imageView.image = [UIImage imageNamed:@"轮播图"];
    [self addSubview:imageView];
    self.bannerImageView = imageView;
    

    
    
    STLabel * nameLable = [[STLabel alloc] initWithFrame:CGRectMake(3, 0, 30, 40)
                                                    text:@"被套"
                                               textColor:FirstTextColor
                                                    font:14
                                             isSizetoFit:NO
                                           textAlignment:NSTextAlignmentLeft];
    [self addSubview:nameLable];
    self.titleLable = nameLable;
    
    
    STLabel * moenLable = [[STLabel alloc] initWithFrame:CGRectMake(3, 0, 80, 33)
                                                    text:@"$100"
                                               textColor:FlatRed
                                                    font:13
                                             isSizetoFit:NO
                                           textAlignment:NSTextAlignmentLeft];
    [self addSubview:moenLable];
    self.moenLable = moenLable;
    
    
    STLabel * pointLable = [[STLabel alloc] initWithFrame:CGRectMake(3, 0, 80, 33)
                                                    text:@"5 + 95"
                                               textColor:FirstTextColor
                                                    font:13
                                              isSizetoFit:NO
                                           textAlignment:NSTextAlignmentLeft];
    [self addSubview:pointLable];
    self.pointLable = pointLable;
    
    self.buyButton  = [[STButton alloc] initWithFrame:CGRectMake(3, 0, 60, 32)
                                                     title:@"购买"
                                                titleColor:FlatRed
                                                 titleFont:14
                                              cornerRadius:4
                                           backgroundColor:nil
                                           backgroundImage:nil
                                                     image:nil];
   
    self.buyButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.buyButton st_setBorderWith:1 borderColor:FlatRed cornerRadius:4];
    self.backgroundColor = UIColor.whiteColor;
    [self addSubview:self.buyButton];
    
}
- (void)layoutSubviews{
    
    self.pointLable.width = self.width;
    self.pointLable.bottom = self.height - 5;
    self.pointLable.left = 3;
    
    self.moenLable.width = self.width;
    self.moenLable.bottom = self.pointLable.top;
     self.moenLable.left = 3;
    
    self.titleLable.width = self.width - 30;
    self.titleLable.bottom = self.moenLable.top;
    self.titleLable.left = 3;

    
    self.bannerImageView.width = self.width;
    self.bannerImageView.height = self.titleLable.top ;
    self.bannerImageView.left = 0;
    
    if (self.width > UIScreenWidth / 2) {
        self.pointLable.width = self.width - self.height;
        self.pointLable.bottom = self.height - 10;
        self.pointLable.left = self.height + 3;
        
        self.moenLable.width = self.width - self.height;
        self.moenLable.centerY = self.height/2;
        self.moenLable.left = self.height + 3;
        
        self.titleLable.width = self.width - 30 - self.height;
        self.titleLable.top = 10;
        self.titleLable.left = self.height + 3;
        
        
        self.bannerImageView.width = self.height;
        self.bannerImageView.height = self.height ;
        self.bannerImageView.left = 0;
    }
    self.buyButton.centerY = self.moenLable.centerY + (self.pointLable.centerY - self.moenLable.centerY ) / 2;
    self.buyButton.right = self.width - 5;
    
    [self st_setBorderWith:0.5 borderColor:FirstTextColor cornerRadius:4];
}
//- (void)setModel:(GHGoodItemModel *)model{
//    _model = model;
//    [self.bannerImageView sd_setImageWithURL:[NSURL URLWithString:model.mainpicture]];
//    self.titleLable.text = model.title;
//    self.moenLable.text = [NSString stringWithFormat:@"￥%0.2f",
//                           model.nowprice.floatValue];
//}
//- (void)updateRankWithIndexPath:(NSIndexPath *)indexPath{
//    NSInteger ranke = indexPath.row  + 1;
//    self.rankeLable.text = [NSString stringWithFormat:@"NO.%ld",ranke];
//    if (ranke == 1) {
//        self.rankeLable.backgroundColor = FlatRed;
//    }else if (ranke == 2){
//        self.rankeLable.backgroundColor = FlatOrange;
//    }else if (ranke == 3){
//        self.rankeLable.backgroundColor = [FlatOrange colorWithAlphaComponent:0.7];
//    }else{
//        self.rankeLable.backgroundColor = FlatGray;
//    }
//}
@end
